package com.xiaoxin.suma.utils;

import android.app.Activity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by ljman on 2017/1/12.
 */

public class ActivityManager {
    private List<Activity> activityList;
    private static ActivityManager instance;

    private ActivityManager() {
        activityList = new ArrayList<>();
    }

    public static synchronized ActivityManager getInstance() {
        if (instance == null)
            instance = new ActivityManager();
        return instance;
    }

    public void addActivity(Activity activity) {
        activityList.add(activity);
    }

    public void removeActivity(Activity activity) {
        activityList.remove(activity);
    }

    public void finishAll() {
        for (Activity a : activityList) {
            a.finish();
        }
    }
}
